import javax.xml.transform.Result;
import java.sql.*;

public class TestJDBC {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {

        //加载驱动
        //Class.forName("com.mysql.jdbc.Driver");
        Class.forName("com.mysql.jdbc.Driver");
        //获取地址
        //jdbc url  jdbc:mysql://localhost:3306/myschool
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/myschool2?useSSL=false","root","123456");
        System.out.println(conn);
        //创建statement
        Statement st = conn.createStatement();
        //操作

        ResultSet rs = st.executeQuery("select name from xueyuan");
        while(rs.next()){
            System.out.println(rs.getString("name"));
        }
        rs.close();
        //关闭连接
        conn.close();
    }
}


